package 一维数组模拟栈数据结构;

public class MyStack {
    Object[] elements;
    int a;
    public MyStack(Object[] elements){
        this.elements = elements;
    }

    public void push(Object[] num){
        if(a + num.length > 100){
            System.out.println("栈已满");
            return;
        }else if(a + num.length > 99){
            System.out.println("栈还有一个空间");
        }
        System.arraycopy(num,0,elements,a,num.length);
        this.a = a + num.length;
    }

    public void pop(int num){
        if(a - num == 0){
            System.out.println("栈已空");
            return;
        }else if(a - num == 1){
            System.out.println("栈只有一个空间了");
        }else if(a - num < 0){

        }
        System.arraycopy(new Object[num],0,elements,a - num,num);
        this.a = a - num;
    }
}
